﻿<!DOCTYPE html>
<html ng-app="demoApp">
<head>
    <title id='Description'>In this demo the AngularJS DropDownList is bound to XML data.</title>
    <meta name="description" content="AngularJS DropDownList example. This example demonstrates a DropDownList data binding to XML data." /> 
    <link rel="stylesheet" href="../../../jqwidgets/styles/jqx.base.css" type="text/css" />
    <script type="text/javascript" src="../../../scripts/angular.min.js"></script>
    <script type="text/javascript" src="../../../scripts/jquery-1.11.1.min.js"></script>
    <script type="text/javascript" src="../../../jqwidgets/jqxcore.js"></script>
    <script type="text/javascript" src="../../../scripts/demos.js"></script>
    <script type="text/javascript" src="../../../jqwidgets/jqxdata.js"></script>
    <script type="text/javascript" src="../../../jqwidgets/jqxbuttons.js"></script>
    <script type="text/javascript" src="../../../jqwidgets/jqxscrollbar.js"></script>
    <script type="text/javascript" src="../../../jqwidgets/jqxlistbox.js"></script>
    <script type="text/javascript" src="../../../jqwidgets/jqxdropdownlist.js"></script>
    <script type="text/javascript" src="../../../jqwidgets/jqxangular.js"></script>
    <script type="text/javascript">
        var demoApp = angular.module("demoApp", ["jqwidgets"]);
        demoApp.controller("demoController", function ($scope) {
            var url = "../../sampledata/customers.xml";

            // prepare the data
            var source =
            {
                datatype: "xml",
                datafields: [
                    { name: 'CompanyName', map: 'm\\:properties>d\\:CompanyName' },
                    { name: 'ContactName', map: 'm\\:properties>d\\:ContactName' },
                ],
                root: "entry",
                record: "content",
                id: 'm\\:properties>d\\:CustomerID',
                url: url
            };

            var dataAdapter = new $.jqx.dataAdapter(source, { async: false });

            // Create a jqxListBox
            $scope.settings = { source: dataAdapter, displayMember: "ContactName", valueMember: "CompanyName", width: 200, height: 25 };
            $scope.selectItem = function (event) {
                if (event.args) {
                    var item = event.args.item;
                    if (item) {
                        $scope.log = "Value: " + item.value + ", Label: " + item.label;
                    }
                }
            };
        });
    </script>
</head>
<body ng-controller="demoController">
    <jqx-drop-down-list jqx-on-select="selectItem(event)" jqx-settings="settings"></jqx-drop-down-list>
    {{log}}
</body>
</html>
